Skip to content

feat: per-task dead-letter list + purge#314

Merged
pratyush618 merged 7 commits into
masterfrom
feat/per-task-dlq
Jun 27, 2026
Merged

feat: per-task dead-letter list + purge#314
pratyush618 merged 7 commits into
masterfrom
feat/per-task-dlq

Conversation

@pratyush618

@pratyush618 pratyush618 commented Jun 27, 2026

Copy link
Copy Markdown
Collaborator

What

Task-scoped dead-letter management across all four SDKs: list / purge DLQ entries for a single task. The existing DLQ surface only worked by id or over the whole queue.

Why a core op (not a client-side filter)

list_dead is paginated (limit/offset) over the entire DLQ, so filtering by task in the client breaks pagination (you filter one page at a time). Correct paging needs server-side filtering — so two ops are added once in the core and shared by every SDK.

Layers

  • core: list_dead_by_task(task, limit, offset) + purge_dead_by_task(task) on the Storage trait + SQLite/Postgres/Redis + delegate. Diesel filters by task_name; Redis scans dlq:all and filters in memory (no secondary index — matches the periodic fix).
  • python: native dead_letters_by_task / purge_dead_by_task + stubs.
  • java: Queue.listDeadByTask / purgeDeadByTask + in-memory test-support impl.
  • node: Queue.deadLettersByTask / purgeDeadByTask.

Verification

  • New backend-parity contract test test_dead_letter_by_task — green on SQLite + Redis (live, local docker); Postgres compiles + runs in CI. Covers list, pagination, purge, and that another task's entries survive.
  • Java DeadLetterByTaskTest (JNI-backed, fail→DLQ→query/purge) and a Node inspection.test.ts case — both live.
  • cargo check default + postgres + redis; cargo clippy clean; full ./gradlew build green; Node 185 tests + typecheck + biome clean; Python ruff + mypy clean.

This completes the P14 scope (retry backoff #311, periodic CRUD #313, per-task DLQ here).

Summary by CodeRabbit

  • New Features

    • Added task-specific dead-letter queue tools across the API surface, including listing dead jobs by task with pagination and purging all dead jobs for a task.
    • Exposed the new controls in Java, Node, Python, and backend storage interfaces.
  • Tests

    • Added coverage to verify per-task dead-letter listing, pagination, and task-scoped purging across supported backends and SDKs.

list_dead_by_task / purge_dead_by_task across SQLite/Postgres/Redis. Diesel filters by task_name; Redis scans dlq:all and filters (no secondary index).
Queue.listDeadByTask / purgeDeadByTask over the new core ops, with an in-memory backend impl. Live-verified by DeadLetterByTaskTest.
Queue.deadLettersByTask / purgeDeadByTask over the new core ops.
@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@pratyush618, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 34 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e2008b93-cc43-4276-a776-441309abd9df

📥 Commits

Reviewing files that changed from the base of the PR and between 121c192 and 234682b.

📒 Files selected for processing (4)
  • crates/taskito-core/src/storage/diesel_common/dead_letter.rs
  • crates/taskito-core/src/storage/redis_backend/dead_letter.rs
  • sdks/java/test-support/src/main/java/org/byteveda/taskito/test/InMemoryQueueBackend.java
  • sdks/node/test/core/inspection.test.ts
📝 Walkthrough

Walkthrough

Task-scoped dead-letter listing and purge APIs are added to core storage and exposed through Java, Node, and Python bindings. The new list methods support pagination and the purge methods return removed counts.

Changes

Task-scoped dead-letter APIs

Layer / File(s) Summary
Storage contract and Diesel wiring
crates/taskito-core/src/storage/traits.rs, crates/taskito-core/src/storage/mod.rs, crates/taskito-core/src/storage/diesel_common/dead_letter.rs
Storage and its Diesel dispatch/implementation add list_dead_by_task and purge_dead_by_task for task_name-scoped DLQ rows.
Redis task-scoped DLQ operations
crates/taskito-core/src/storage/redis_backend/dead_letter.rs
Redis DLQ listing filters by task_name after scanning dlq:all, paginates the matches, and purge deletes matching entries and removes their IDs from the sorted set.
Java JNI and SDK surface
crates/taskito-java/src/queue/admin.rs, sdks/java/src/main/java/org/byteveda/taskito/..., sdks/java/test-support/src/main/java/org/byteveda/taskito/test/InMemoryQueueBackend.java, sdks/java/src/test/java/org/byteveda/taskito/DeadLetterByTaskTest.java
Java adds task-scoped dead-letter list and purge methods across JNI, backend adapters, public interfaces, in-memory support, and a per-task integration test.
Node binding and test
crates/taskito-node/src/queue/admin.rs, sdks/node/src/queue.ts, sdks/node/test/core/inspection.test.ts
Node exposes deadLettersByTask and purgeDeadByTask on Queue and adds test coverage for per-task listing, pagination, and purge behavior.
Python binding surface
crates/taskito-python/src/py_queue/inspection.rs, sdks/python/taskito/_taskito.pyi
Python adds dead_letters_by_task and purge_dead_by_task to PyQueue and updates the type stub signatures.
Rust storage contract tests
crates/taskito-core/tests/rust/storage_tests.rs
The shared storage test suite adds a task-scoped dead-letter case and registers it in the generic harness.

Sequence Diagram(s)

sequenceDiagram
  participant DefaultQueue
  participant JniQueueBackend
  participant NativeQueue
  participant StorageBackend
  participant RedisStorage

  DefaultQueue->>JniQueueBackend: listDeadByTask(taskName, limit, offset)
  JniQueueBackend->>NativeQueue: listDeadByTaskJson(handle, taskName, limit, offset)
  NativeQueue->>StorageBackend: list_dead_by_task(task_name, limit, offset)
  StorageBackend->>RedisStorage: list_dead_by_task(task_name, limit, offset)
  RedisStorage-->>StorageBackend: Vec<DeadJob>
  StorageBackend-->>NativeQueue: Vec<DeadJob>
  NativeQueue-->>JniQueueBackend: JSON string
  JniQueueBackend-->>DefaultQueue: JSON string
  DefaultQueue->>DefaultQueue: decode DeadJob[]

  DefaultQueue->>JniQueueBackend: purgeDeadByTask(taskName)
  JniQueueBackend->>NativeQueue: purgeDeadByTask(handle, taskName)
  NativeQueue->>StorageBackend: purge_dead_by_task(task_name)
  StorageBackend->>RedisStorage: purge_dead_by_task(task_name)
  RedisStorage-->>StorageBackend: deleted count
  StorageBackend-->>NativeQueue: deleted count
  NativeQueue-->>JniQueueBackend: jlong count
  JniQueueBackend-->>DefaultQueue: long count
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • ByteVeda/taskito#207: Shares the dead-letter Diesel storage layer that this PR extends with task-scoped list and purge operations.
  • ByteVeda/taskito#236: Modifies the same dead-letter storage and backend contract area that now carries the new per-task inspection and purge methods.

Poem

I hop by task with ears aflutter,
I count each DLQ crumb and mutter.
One purge, one list, neat and true,
Then off I bounce to code review. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 59.26% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding per-task dead-letter listing and purge APIs.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/per-task-dlq

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/taskito-core/src/storage/diesel_common/dead_letter.rs`:
- Around line 97-110: Normalize pagination inputs in list_dead_by_task so the
SQL backend matches Redis behavior: treat any limit <= 0 as returning an empty
result immediately, and clamp any negative offset to 0 before building the
dead_letter query. Apply this in the dead_letter.rs implementation around
list_dead_by_task, using the existing dead_letter::table query path and
DeadLetterRow::as_select() flow, so callers get consistent backend parity
regardless of signed inputs.

In `@crates/taskito-core/src/storage/redis_backend/dead_letter.rs`:
- Around line 174-191: The pagination target in the dead-letter scan can
overflow because `offset` and `limit` are cast from public `i64` inputs before
being added in the `dead_letter` lookup logic. Update the match-limit check in
this path to use a saturating or checked addition for the page target, and keep
the early-break behavior in the `DeadJob`/`DeadJobEntry` scan unchanged
otherwise.
- Around line 213-219: The DLQ purge logic in dead_letter.rs currently ignores
records that fail deserialization in the entry scan and still reports success,
which can hide skipped task-owned entries. Update the purge flow around the
DeadJobEntry parsing path so unreadable records are treated as an error or
otherwise surfaced instead of silently continuing, and make sure the returned
removed count only reflects entries that were actually verified and deleted in
the purge routine.

In
`@sdks/java/test-support/src/main/java/org/byteveda/taskito/test/InMemoryQueueBackend.java`:
- Around line 266-270: The purgeDeadByTask method in InMemoryQueueBackend is not
synchronized with the DLQ write path, so its before - dead.size() count can race
with onFail(...) appending to dead. Make the remove-and-count operation atomic
by performing the purge while holding the same backend monitor used by the other
dead-queue mutations, and compute the removed count from that synchronized
section so matching entries added concurrently cannot slip through.

In `@sdks/node/test/core/inspection.test.ts`:
- Around line 79-82: The async polling in inspection.test.ts is too aggressive
and can flake while waiting for the worker to start, fail three jobs, and
persist DLQ rows. Increase the wait budget in the deadLetters check or switch
this block to the same eventual-wait helper used by the other async tests,
keeping the logic around queue.deadLetters() and the polling loop intact.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c5e4374-e221-44d7-aaa0-6149e070d7d2

📥 Commits

Reviewing files that changed from the base of the PR and between d8606ab and 121c192.

📒 Files selected for processing (18)
  • crates/taskito-core/src/storage/diesel_common/dead_letter.rs
  • crates/taskito-core/src/storage/mod.rs
  • crates/taskito-core/src/storage/redis_backend/dead_letter.rs
  • crates/taskito-core/src/storage/traits.rs
  • crates/taskito-core/tests/rust/storage_tests.rs
  • crates/taskito-java/src/queue/admin.rs
  • crates/taskito-node/src/queue/admin.rs
  • crates/taskito-python/src/py_queue/inspection.rs
  • sdks/java/src/main/java/org/byteveda/taskito/DefaultQueue.java
  • sdks/java/src/main/java/org/byteveda/taskito/Queue.java
  • sdks/java/src/main/java/org/byteveda/taskito/internal/JniQueueBackend.java
  • sdks/java/src/main/java/org/byteveda/taskito/internal/NativeQueue.java
  • sdks/java/src/main/java/org/byteveda/taskito/spi/QueueBackend.java
  • sdks/java/src/test/java/org/byteveda/taskito/DeadLetterByTaskTest.java
  • sdks/java/test-support/src/main/java/org/byteveda/taskito/test/InMemoryQueueBackend.java
  • sdks/node/src/queue.ts
  • sdks/node/test/core/inspection.test.ts
  • sdks/python/taskito/_taskito.pyi

Comment thread crates/taskito-core/src/storage/diesel_common/dead_letter.rs
Comment thread crates/taskito-core/src/storage/redis_backend/dead_letter.rs Outdated
Comment thread crates/taskito-core/src/storage/redis_backend/dead_letter.rs
Comment thread sdks/node/test/core/inspection.test.ts Outdated
Diesel now clamps limit/offset like Redis (non-positive limit = empty page); Redis purge propagates a deserialize error instead of silently skipping (which under-reported the count); saturating page target avoids i64->usize overflow.
@pratyush618
pratyush618 merged commit 2a957da into master Jun 27, 2026
34 checks passed
@pratyush618
pratyush618 deleted the feat/per-task-dlq branch June 27, 2026 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant